[id].vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 页面导航 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 广告1 -->
  7. <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item>
  17. <NuxtLink :to="`/${targetSegment}/index.html`">
  18. {{ routLevelTitle }}
  19. </NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <!-- 资讯列表 -->
  26. <div class="newsDetail">
  27. <div class="inner">
  28. <div class="innerLeft">
  29. <div class="LeftTop">
  30. <h1>{{ newsDetail.title }}</h1>
  31. <p>
  32. 来源: <span>{{ newsDetail.copyfrom }}</span>
  33. 作者: <span>{{ newsDetail.author }}</span>
  34. 发布时间: <span>{{ time }}</span>
  35. </p>
  36. </div>
  37. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  38. </div>
  39. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  40. <img :src="selectedImage" alt="Preview">
  41. </div>
  42. <!-- 免责声明: -->
  43. <div class="disclaimer" v-if="newsDetail.fromurl">
  44. <p>原文链接:{{ newsDetail.fromurl }}</p>
  45. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  46. </div>
  47. <div v-if="articleChoice">
  48. <!-- 投票 start ---------------------------------------->
  49. <div class="index_3_box_vote" v-if="articleChoice">
  50. <div class="voteTitle">投票区</div>
  51. <div class="inquire">
  52. <p v-if="voteList.length > 0">{{ voteList[0].survey_name }}</p>
  53. <div class="radioBox">
  54. <!--投票选项-->
  55. <div v-if="!isDisabled">
  56. <div class="radio" v-if="isRadio">
  57. <el-radio-group v-model="radio1" @change="handleRadioChange">
  58. <el-radio v-for="item in voteList" :key="item.id" :value="item.id"
  59. size="large">
  60. <span v-if="item.is_other == 0">{{ item.choice_name }}</span>
  61. <span v-else>其他</span>
  62. </el-radio>
  63. </el-radio-group>
  64. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  65. resize="none" placeholder="请输入.." />
  66. </div>
  67. <div class="checkInputBox" v-else>
  68. <el-checkbox-group v-model="check1" @change="handleCheckboxChange">
  69. <span v-for="item in voteList" :key="item.id">
  70. <span v-if="item.is_other == 0">
  71. <el-checkbox size="large" :label="item.choice_name"
  72. :value="item.id" />
  73. </span>
  74. <span v-else>
  75. <el-checkbox size="large" label="其他" :value="item.id" />
  76. </span>
  77. </span>
  78. </el-checkbox-group>
  79. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  80. resize="none" placeholder="请输入.." />
  81. </div>
  82. </div>
  83. <!--投票结果-->
  84. <div class="inquireData" v-else>
  85. <div v-for="item in websiteSurveyData.data" :key="item.id">
  86. <div class="inquireDataItem active" v-if="item.status == 1">
  87. <div class="inquireDataItemTitle">
  88. <span v-if="item.choice_name == ''">其他</span>
  89. <span v-else>{{ item.choice_name }}</span>
  90. </div>
  91. <div class="inquireDataItemNum">{{ item.results }}票</div>
  92. </div>
  93. <div class="inquireDataItem" v-else>
  94. <div class="inquireDataItemTitle">
  95. <span v-if="item.choice_name == ''">其他</span>
  96. <span v-else>{{ item.choice_name }}</span>
  97. </div>
  98. <div class="inquireDataItemNum">{{ item.results }}票</div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="btn">
  104. <button class="voting" @click="addWebsiteSurvey" :disabled="isDisabled"
  105. v-if="!isDisabled">投票</button>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- 投票 end ---------------------------------------->
  110. </div>
  111. <!-- 推荐阅读 -->
  112. <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  113. <div class="recommendReadTitle">
  114. 推荐阅读
  115. <em></em>
  116. </div>
  117. <div class="recommendReadList">
  118. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  119. :key="item.id">
  120. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  121. {{ item.title }}
  122. </a>
  123. <span v-if="index < 3">{{ getTime(item.created_at,"month",1) }}</span>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <div class="innerRight">
  129. <!-- 热点资讯1 -->
  130. <div class="hotList1">
  131. <DetailHotNews></DetailHotNews>
  132. </div>
  133. <!-- 热点资讯2 -->
  134. <div class="hotList2">
  135. <DetailHotNews2></DetailHotNews2>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <!-- 广告2 -->
  141. <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>
  142. <!-- 页面底部 -->
  143. <HomeFoot1></HomeFoot1>
  144. </template>
  145. <script setup>
  146. //1.页面依赖 start ---------------------------------------->
  147. import { onMounted } from 'vue'
  148. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElMessage, ElCheckboxGroup, ElCheckbox, ElInput } from 'element-plus'
  149. import { ArrowRight } from '@element-plus/icons-vue'
  150. //1.1 获得跳转过来的id
  151. const route = useRoute();
  152. //获得详情id
  153. const articleId = parseInt(route.params.id); //获得该页面的id
  154. //获得当前的完整路径
  155. const fullPath = route.path;
  156. //拆分,取出来中间这一段,然后提取数字部分
  157. const segments = fullPath.split('/');
  158. const targetSegment = segments[1];
  159. // const numberPart = targetSegment.match(/\d+$/)?.[0];
  160. // let routeId = 20 //排除路径错误可以打开这个
  161. // const routeId = numberPart;
  162. let routeId;
  163. //通过导航路径反向查询导航id
  164. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  165. method: 'GET',
  166. query: {
  167. 'pinyin': targetSegment,
  168. },
  169. });
  170. if (getRouteId.code == 200) {
  171. routeId = getRouteId.data.category_id
  172. } else {
  173. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  174. console.log("错误位置:通过url路径查询导航池id")
  175. console.log("后端错误反馈:", getRouteId.message)
  176. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  177. }
  178. //1.2 获得父级栏目的名称、id
  179. const parent_name = ref([]);
  180. const parent_id = ref([]);
  181. const parent_pinyin = ref("");
  182. const parent_children_count = ref(0)
  183. let getParentNav = async () => {
  184. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  185. method: 'GET',
  186. query: {
  187. 'catid': routeId
  188. },
  189. });
  190. console.log("获取父级栏目数据")
  191. console.log(listData)
  192. if (listData.code == 200) {
  193. console.log(listData.data);
  194. parent_name.value = listData.data.alias;
  195. parent_id.value = listData.data.parent_id;
  196. parent_pinyin.value = listData.data.aLIas_pinyin;
  197. parent_children_count = listData.data.children_coun;
  198. } else {
  199. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  200. console.log("错误位置:获取面包屑导航")
  201. console.log("后端错误反馈:", listData.message)
  202. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  203. }
  204. }
  205. //获得父级栏目详情
  206. // getParentNav();
  207. //1.页面依赖 end ---------------------------------------->
  208. //2.页面数据 start ---------------------------------------->
  209. //2.1 资讯详情
  210. const newsDetail = ref({})
  211. const routeNewsTtitle = ref("");
  212. //2.2 发布日期
  213. const time = ref("");
  214. //2.3 路径
  215. const routLevelTitle = ref("");
  216. const routLevelId = ref("");
  217. //是否展示投票
  218. const articleChoice = ref(false);
  219. //2.4获取详情
  220. async function getPageData() {
  221. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  222. method: 'GET',
  223. query: {
  224. 'articleid': articleId
  225. },
  226. });
  227. console.log("资讯详情", mkdata)
  228. if (mkdata.code == 200) {
  229. //判断是否显示投票
  230. if (mkdata.data.is_survey == 1) {
  231. console.log("本篇文章含有投票!")
  232. articleChoice.value = true;
  233. getVoteList();
  234. }
  235. //获取内容
  236. newsDetail.value = mkdata.data;
  237. //获取路径
  238. routLevelTitle.value = newsDetail.value.cat_name;
  239. routLevelId.value = newsDetail.value.category_id;
  240. //获取发布时间
  241. time.value = newsDetail.value.updated_at.split(' ')[0];
  242. //修正标题长度
  243. if (newsDetail.value.title.length >= 20) {
  244. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  245. } else {
  246. routeNewsTtitle.value = newsDetail.value.title
  247. }
  248. } else {
  249. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  250. console.log("错误位置:获取详情内容")
  251. console.log("后端错误反馈:", mkdata.message)
  252. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  253. }
  254. }
  255. getPageData();
  256. //2.5 获得广告
  257. //广告列表
  258. let adImg1 = ref([]);
  259. let adImg2 = ref([]);
  260. onMounted(async () => {
  261. const { $webUrl, $CwebUrl } = useNuxtApp();
  262. //广告1
  263. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_detail_0001`
  264. const responseAd1 = await fetch(url, {
  265. headers: {
  266. 'Content-Type': 'application/json',
  267. 'Userurl': $CwebUrl,
  268. 'Origin': $CwebUrl
  269. }
  270. });
  271. const resultAd1 = await responseAd1.json();
  272. adImg1.value = resultAd1.data[0];
  273. //广告2
  274. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_detail_0002`
  275. const responseAd2 = await fetch(url2, {
  276. headers: {
  277. 'Content-Type': 'application/json',
  278. 'Userurl': $CwebUrl,
  279. 'Origin': $CwebUrl
  280. }
  281. });
  282. const resultAd2 = await responseAd2.json();
  283. adImg2.value = resultAd2.data[0];
  284. })
  285. //2.页面数据 end ---------------------------------------->
  286. //3.设置seo信息 start---------------------------------------->
  287. //3.1 设置seo信息
  288. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  289. method: 'GET',
  290. query: {
  291. 'articleid': articleId
  292. },
  293. });
  294. if (setData.code == 200) {
  295. let seoTitle = setData.data.title;
  296. let seoDescription = setData.data.introduce;
  297. let seoKeywords = setData.data.keyword;
  298. let seoSuffix = setData.data.suffix;
  299. let seoName = setData.data.website_name;
  300. useSeoMeta({
  301. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  302. meta: [
  303. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  304. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  305. ]
  306. });
  307. } else {
  308. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  309. console.log("错误位置:设置详情页面SEO数据")
  310. console.log("后端错误反馈:", setData.message)
  311. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  312. }
  313. //3.设置seo信息 end---------------------------------------->
  314. //4.投票 start---------------------------------------->
  315. const radio1 = ref(''); //单选
  316. const check1 = ref([]); //多选
  317. const isDisabled = ref(false);//是否禁用提交按钮
  318. const isRadio = ref(true);//是否渲染单选
  319. const userSurId = ref('');//投票属于哪一篇文章
  320. const userChoice = ref('');//用于判断用户选择了其他选项以后,输入的值
  321. const userIsChoice = ref('');//用于判断其他选项目前是什么值
  322. const showUserChoice = ref(false);//是否显示其他输入框
  323. const websiteSurveyData = ref([]);//投票结果
  324. //3.2获得投票列表
  325. let voteList = ref([]);
  326. async function getVoteList() {
  327. const voteData = await requestHome('/web/getWebsiteSurvey', { method: 'GET', query: { 'art_id': articleId } });
  328. console.log(778899)
  329. console.log('778899', voteData)
  330. if (voteData.code == 200) {
  331. voteList.value = voteData.data;
  332. console.log(voteList.value)
  333. //判断显示单选还是多选
  334. //survey_type 0是单选 1是多选
  335. if (voteData.data[0].survey_type == 0) {
  336. isRadio.value = true;
  337. console.log("1111")
  338. } else {
  339. isRadio.value = false;
  340. }
  341. //把最后一个的值拿出来 用于判断用户是否选择了其他
  342. for (let item of voteData.data) {
  343. //如果含有其他
  344. if (item.is_other == 1) {
  345. userIsChoice.value = item.id;
  346. }
  347. }
  348. //用户投票属于哪一篇文章
  349. userSurId.value = voteData.data[0].sur_id;
  350. } else {
  351. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  352. console.log("错误位置:首页投票")
  353. console.log("后端错误反馈:", voteData.message)
  354. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  355. }
  356. }
  357. //3.2当用户选择了选项,判断是否展示其他输入框
  358. const handleRadioChange = (value) => {
  359. console.log('11111', value, userIsChoice.value);
  360. if (value == userIsChoice.value) {
  361. showUserChoice.value = true;
  362. } else {
  363. showUserChoice.value = false;
  364. }
  365. }
  366. const handleCheckboxChange = (value) => {
  367. if (value.includes(userIsChoice.value)) {
  368. showUserChoice.value = true;
  369. } else {
  370. showUserChoice.value = false;
  371. }
  372. }
  373. //3.2发起投票
  374. async function addWebsiteSurvey() {
  375. //判断当前是单选还是多选
  376. console.log(isRadio.value)
  377. if (isRadio.value) {
  378. console.log("用户单选!")
  379. if (radio1.value != '') {
  380. //先判断一下是否使用了其他选项
  381. if (showUserChoice.value) {
  382. if (userChoice.value != '') {
  383. //文章id
  384. // console.log(userSurId.value)
  385. // 用户输入的值
  386. // console.log(userChoice.value)
  387. //如果使用了其他,其他的选项需要增加进去
  388. const ChoiceData = await requestHome('/web/addWebsiteSurveyOption', {
  389. method: 'GET',
  390. query: {
  391. 'sur_id': userSurId.value,//投票的新闻id
  392. 'choice_name': userChoice.value,//投票的选项id
  393. }
  394. });
  395. if (ChoiceData.code == 200) {
  396. //提交完其他选项以后,再正式发起投票
  397. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  398. method: 'GET',
  399. query: {
  400. 'sur_id': userSurId.value,
  401. 'choice_id': ChoiceData.data
  402. }
  403. });
  404. if (mkData.code == 200) {
  405. ElMessage.success('投票成功!')
  406. //把投票结果显示到页面上 禁用投票按钮
  407. isDisabled.value = true;
  408. websiteSurveyData.value = mkData.data;
  409. //遍历一下,把用户选中的那个设置status为1
  410. let data = mkData.data;
  411. //遍历一下,把用户选中的那个设置status为1
  412. for (let item of data.data) {
  413. for (let i of data.choice) {
  414. if (item.id == i) {
  415. console.log(item.id)
  416. item.status = 1;
  417. }
  418. }
  419. }
  420. websiteSurveyData.value = data;
  421. } else {
  422. ElMessage.error(mkData.message)
  423. }
  424. } else {
  425. ElMessage.error('其他投票失败!')
  426. }
  427. } else {
  428. ElMessage.error('请输入选项内容!')
  429. }
  430. } else {
  431. console.log('111', userSurId.value);
  432. console.log('222', radio1.value);
  433. //如果没选择其他,直接提交选择的内容
  434. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  435. method: 'GET',
  436. query: {
  437. 'sur_id': userSurId.value,
  438. 'choice_id': radio1.value
  439. }
  440. });
  441. if (mkData.code == 200) {
  442. ElMessage.success('投票成功!')
  443. //把投票结果显示到页面上 禁用投票按钮
  444. isDisabled.value = true;
  445. let data = mkData.data;
  446. //遍历一下,把用户选中的那个设置status为1
  447. for (let item of data.data) {
  448. for (let i of data.choice) {
  449. if (item.id == i) {
  450. item.status = 1;
  451. }
  452. }
  453. }
  454. websiteSurveyData.value = data;
  455. } else {
  456. ElMessage.error('投票失败!')
  457. }
  458. }
  459. } else {
  460. ElMessage.error('请选择一个选项')
  461. }
  462. } else {
  463. console.log("多选!")
  464. //多选
  465. if (check1.value != []) {
  466. //先判断一下是否使用了其他选项
  467. if (showUserChoice.value) {
  468. if (userChoice.value != '') {
  469. //判断用户是否只选择了一个其他
  470. if (check1.value.length == 1) {
  471. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  472. method: 'GET',
  473. query: {
  474. 'sur_id': userSurId.value,//投票的新闻id
  475. 'choice_name': userChoice.value,//用户输入的其他选项文字
  476. }
  477. });
  478. if (ChoiceData.code == 200) {
  479. //提交完其他选项以后,再正式发起投票
  480. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  481. method: 'GET',
  482. query: {
  483. 'sur_id': userSurId.value,
  484. 'choice_id': ChoiceData.data
  485. }
  486. });
  487. if (mkData.code == 200) {
  488. ElMessage.success('投票成功!')
  489. //把投票结果显示到页面上 禁用投票按钮
  490. isDisabled.value = true;
  491. websiteSurveyData.value = mkData.data;
  492. //遍历一下,把用户选中的那个设置status为1
  493. let data = mkData.data;
  494. //遍历一下,把用户选中的那个设置status为1
  495. for (let item of data.data) {
  496. for (let i of data.choice) {
  497. if (item.id == i) {
  498. console.log(item.id)
  499. item.status = 1;
  500. }
  501. }
  502. }
  503. websiteSurveyData.value = data;
  504. } else {
  505. ElMessage.error(mkData.message)
  506. }
  507. } else {
  508. ElMessage.error('其他投票失败!')
  509. }
  510. } else {
  511. //用户选择了除了其他以外,还包括别的选项
  512. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  513. method: 'GET',
  514. query: {
  515. 'sur_id': userSurId.value,//投票的新闻id
  516. 'choice_name': userChoice.value,//用户输入的其他选项文字
  517. }
  518. });
  519. if (ChoiceData.code == 200) {
  520. let data = check1.value;
  521. //找到多选的数组,把其他默认值给替换掉
  522. for (let i = 0; i < data.length; i++) {
  523. if (data[i] == userIsChoice.value) {
  524. data[i] = ChoiceData.data;
  525. }
  526. }
  527. let jsonArray = JSON.stringify(data);
  528. //提交完其他选项以后,再正式发起投票
  529. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  530. method: 'GET',
  531. query: {
  532. 'sur_id': userSurId.value,
  533. 'choice_id': jsonArray
  534. }
  535. });
  536. if (mkData.code == 200) {
  537. ElMessage.success('投票成功!')
  538. //把投票结果显示到页面上 禁用投票按钮
  539. isDisabled.value = true;
  540. websiteSurveyData.value = mkData.data;
  541. //遍历一下,把用户选中的那个设置status为1
  542. let data = mkData.data;
  543. //遍历一下,把用户选中的那个设置status为1
  544. for (let item of data.data) {
  545. for (let i of data.choice) {
  546. if (item.id == i) {
  547. //console.log(item.id)
  548. item.status = 1;
  549. }
  550. }
  551. }
  552. websiteSurveyData.value = data;
  553. } else {
  554. ElMessage.error(mkData.message)
  555. }
  556. } else {
  557. ElMessage.error('其他投票失败!')
  558. }
  559. }
  560. } else {
  561. ElMessage.error('请输入选项内容!')
  562. }
  563. } else {
  564. let jsonArray = JSON.stringify(check1.value);
  565. //如果没选择其他,直接提交选择的内容
  566. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  567. method: 'GET',
  568. query: {
  569. 'sur_id': userSurId.value,
  570. 'choice_id': jsonArray
  571. }
  572. });
  573. if (mkData.code == 200) {
  574. ElMessage.success('投票成功!')
  575. //把投票结果显示到页面上 禁用投票按钮
  576. isDisabled.value = true;
  577. websiteSurveyData.value = mkData.data;
  578. //遍历一下,把用户选中的那个设置status为1
  579. let data = mkData.data;
  580. //遍历一下,把用户选中的那个设置status为1
  581. for (let item of data.data) {
  582. for (let i of data.choice) {
  583. if (item.id == i) {
  584. console.log(item.id)
  585. item.status = 1;
  586. }
  587. }
  588. }
  589. websiteSurveyData.value = data;
  590. } else {
  591. ElMessage.error('投票失败!')
  592. }
  593. }
  594. } else {
  595. ElMessage.error('请选择一个选项')
  596. }
  597. }
  598. }
  599. //4.投票 end---------------------------------------->
  600. //5.页面图片放大 start---------------------------------------->
  601. const previewVisible = ref(false)
  602. const selectedImage = ref(' ')
  603. const openPreview = (event) => {
  604. if (event.target.tagName === 'IMG') {
  605. selectedImage.value = event.target.src;
  606. previewVisible.value = true;
  607. }
  608. }
  609. const closePreview = () => {
  610. previewVisible.value = false;
  611. }
  612. //5.页面图片放大 end---------------------------------------->
  613. </script>
  614. <style lang="less" scoped>
  615. @import url('@/assets/css/detail.less');
  616. </style>